package com.gaogzhen.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gaogzhen.domain.CoinRecharge;
import com.gaogzhen.service.CoinRechargeService;
import com.gaogzhen.utils.CurrentUser;
import com.gaogzhen.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @author Administrator
 * @version 1.0
 * @description
 * @date 2022-11-10 11:49
 */
@RestController
@RequestMapping("/coinRecharges")
@Api(tags = "充币控制器")
public class CoinRechargeController {

    @Autowired
    private CoinRechargeService service;

    @GetMapping("/records")
    @ApiOperation(value = "分页查询充币记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name ="coinId" ,value = "币种id"),
            @ApiImplicitParam(name ="userId" ,value = "用户id"),
            @ApiImplicitParam(name ="username" ,value = "用户名"),
            @ApiImplicitParam(name ="mobile" ,value = "手机号"),
            @ApiImplicitParam(name ="status" ,value = "状态"),
            @ApiImplicitParam(name ="numMin" ,value = "充值金额下限"),
            @ApiImplicitParam(name ="numMax" ,value = "充值金额上限"),
            @ApiImplicitParam(name ="startTime" ,value = "开始时间"),
            @ApiImplicitParam(name ="endTime" ,value = "终止时间"),
            @ApiImplicitParam(name ="current" ,value = "当前页"),
            @ApiImplicitParam(name ="size" ,value = "每页条目"),
    })
    public R<Page<CoinRecharge>> findByPage(
            Page<CoinRecharge> page, Long coinId, Long userId, String username, String mobile, Byte status,
            String numMin, String numMax, String startTime, String endTime) {

        return R.ok(service.findByPage(page, coinId, userId, username, mobile, status, numMin, numMax, startTime, endTime));
    }

    @GetMapping("/user/record")
    @ApiOperation(value = "分页查询当前用户充币记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name ="coinId" ,value = "币种id"),
            @ApiImplicitParam(name ="current" ,value = "当前页"),
            @ApiImplicitParam(name ="size" ,value = "每页条目"),
    })
    public R<Page<CoinRecharge>> findCurrentByPage(@ApiIgnore Page<CoinRecharge> page, Long coinId) {
        return R.ok(service.findCurrentByPage(CurrentUser.getCurrentUserId(), page, coinId));
    }
}
